home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctj1086.arc
/
READDIR2.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-08-14
|
2KB
|
88 lines
;LISTING 2: READDIR2.ASM
;
; This program reads the directory from the diskette in drive A.
; The input buffer area is outside the program's segment and is
; obtained from the DOS memory pool by calling DOS Function 48H,
; after calling DOS Function 4AH to "shrink" the memory allocated
; to the program. For the sake of simplicity no console input or
; output functions are performed by this program.
;
CODESEG SEGMENT PARA PUBLIC 'CODE'
;
;
ASSUME CS:CODESEG,DS:CODESEG,ES:CODESEG,SS:CODESEG
;
ORG 0100H
;
BEGIN: JMP READ_DIRECTORY
;
; ************************ Main Procedure **************************
;
READ_DIRECTORY:
;
; "Shrink" the program memory allocation by calling DOS Function 4AH
;
MOV BX,4096 ; 64K for the program
MOV AH,4AH ; DOS function
INT 21H ; Function request
JC ERROR_EXIT_1 ; Quit if there was an error
;
; Request DOS to allocate a block of memory for the disk input area
;
MOV BX,224 ; Room for 7 sectors
MOV AH,48H ; DOS function
INT 21H ; Function Request
JC ERROR_EXIT_1 ; Quit if there was an error
MOV ES,AX ; Move segment from AX to ES
;
; Set breakpoint for DEBUG so that the registers can be examined
;
INT 03H ; DEBUG breakpoint
;
; Setup DS for the Absolute Disk Read
;
PUSH DS ; Save DS
MOV AX,ES ; MOVE the contents of ES to DS
MOV DS,AX ; via AX
;
; Setup the registers for the Absolute Disk Read
;
MOV AL,00H ; Drive A
XOR BX,BX ; Point to the beginning
; of the memory area
MOV CX,0007H ; 7 sectors to be read
MOV DX,0005H ; Start at sector 5
INT 25H ; Absolute Disk Read Interrupt
JC ERROR_EXIT_2 ; Quit if there was an error
POPF ; Restore the user flags
POP DS ; Restore DS
;
; Free the allocated memory block prior to returning to DOS
;
MOV AH,49H ; DOS function
INT 21H ; Function Request
RET ; Return to DOS
;
; Error return without popping the stack
;
ERROR_EXIT_1:
RET ;Return to DOS
;
; Error return with popping the stack
;
ERROR_EXIT_2:
POP DI ; Throw away the user flags
POP DS ; Restore DS
;
; Free the allocated memory block prior to returning to DOS
;
MOV AH,49H ; DOS function
INT 21H ; Function Request
RET ; Return to DOS
;
CODESEG ENDS
;
; ********************************************************************
;
END BEGIN